from rest_framework import serializers

from apps.commom.address import AddressSerializer
from models.models import OrderInfo, VipOrderInfo, AgentOrderInfo


class OrderInfoSerializer(serializers.ModelSerializer):
    address = serializers.SerializerMethodField()

    def get_address(self, obj):
        return AddressSerializer(obj.address).data

    class Meta:
        model = OrderInfo
        fields = "__all__"


class VipOrderInfoSerializer(serializers.ModelSerializer):
    class Meta:
        model = VipOrderInfo
        fields = "__all__"


class AgentOrderInfoSerializer(serializers.ModelSerializer):
    package = serializers.SerializerMethodField()

    def get_package(self, obj):
        return obj.package.name

    class Meta:
        model = AgentOrderInfo
        fields = "__all__"
